package com.ums.scumspay.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.ums.scumspay.common.Resp;
import com.ums.scumspay.entity.PayOrder;
import com.ums.scumspay.entity.resp.PayOrderPosResp;
import com.ums.scumspay.entity.resp.PayOrderReDataResp;
import com.ums.scumspay.service.PayOrderService;
import com.ums.scumspay.utils.RandomUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.text.SimpleDateFormat;
import java.util.Date;

@RestController
@RequestMapping("/payInfo")
public class PayOrderController {

    @Autowired
    private PayOrderService payOrderService;

    @PostMapping("/pos")
    public Resp<PayOrderPosResp> getPosPayInfo(@RequestParam("transDate") String transDate){
        return payOrderService.getPosPayInfo(transDate);
    }

    @PostMapping("/qrCode")
    public Resp<PayOrderPosResp> getQrCodePayInfo(@RequestParam("transDate") String transDate){
        return payOrderService.getQrCodePayInfo(transDate);
    }

    @PostMapping("/reconciliation")
    public Resp<PayOrderReDataResp> reconciliation(@RequestParam("transDate") String transDate){
        return payOrderService.reconciliation(transDate);
    }

    @GetMapping("/111")
    public void reconciliation(){
        payOrderService.createFile();
        // PayOrder one = payOrderService.getOne(new LambdaQueryWrapper<PayOrder>().eq(PayOrder::getTransNo, "8888202309183814452987501988"));
        // one.setId(null);
        // one.setTransNo("8888"+new SimpleDateFormat("yyyyMMddmmHHssSSS").format(new Date())+ RandomUtils.getRandomNum(7));
        // one.setPayStatus("02");
        // one.setRefundSign("1");
        // payOrderService.save(one);
    }

}
